<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>签约网</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>

</head>
<body>
<div id="secHeader">
  <header class="header">
      <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
      <h2>找回密码</h2>
      <!--<a href="javascript:void(0);" onclick="aaplay('index','login_tel.html')" class="qiandao_btn">直接登录</a>-->
  </header>
</div>
<section class="login_section">
    <div class="fyb_logo"><img src="http://index.gfjijin.cn/img/logo.png" alt=""></div>
    <div class="login_box">
        <ul>
            <li class="username"><input type="text" placeholder="请输入手机号" name="phone" id='phone'></li>
            <li class="tel_code"><input type="text" name="yzm" placeholder="请输入验证码"><span id='regyzm'>获取验证码</span></li>
            <li class="tel_code"><input style="width: 100%;" name="pwd" type="password" placeholder="请设置密码"></li>
            <li class="tel_code"><input style="width: 100%;" type="password" name="npwd" placeholder="再次输入新密码"></li>
        </ul>
        <button class="login_submit" onclick="changePwd()" style="margin-top: 1rem" type="submit">确认</button>
    </div>

</section>

<!--<include file="Public/userfooter" />-->
<script type="text/javascript" src="../script/lawyer_user.js"></script>

</body>
<script>
    apiready = function () {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){

        });
        api.showProgress();
    }

    $('#regyzm').click(function () {
        if($(this).hasClass('regyzm')==false){
            var phone=$('input[name=phone]').val();
            if(phone==''){
                api.alert({msg:"请输入手机号！"});return;
            }else if(!/^1[345678]\d{9}$/.test(phone)){
                api.alert({msg:"手机号格式错误！"});return;
            }



            var p={phone:phone,type:1};
            $.post(webSiteUrl+'/app/public/yzm',p,function(ret){
                if(ret.code==200){

                    $('#regyzm').addClass('regyzm');
                    var num=60;
                    timer=setInterval(function(){
                        $('#regyzm').html(num+'秒');
                        num--;
                        if(num==0){
                            clearInterval(timer);
                            timer=null;
                            $('#regyzm').html('重新获取');
                            $('#regyzm').removeClass('regyzm');
                        }
                    },1000)

                    alert(ret.msg);


                }else{alert(ret.msg)}
            });

        }
    })


    function changePwd(){
        var xx = '{$get["type"]}';

        if(xx==undefined||xx==null||xx==''){
            xx=1;
        }else {
            xx=2;
        }
        console.log(xx);
        var phone=$("input[name=phone]").val();
        var yzm=$("input[name=yzm]").val();
        var pwd=$("input[name=pwd]").val();
        var npwd=$("input[name=npwd]").val();
        if(phone==''){
            alert("请输入手机号！");return;
        }/*else if(!/^1[345678]\d{9}$/.test(phone)){
            alert("手机号格式错误！");return;
        }*//*else if(yzm==''){
            alert("请输入验证码！");return;
        }*/
        if(pwd !=npwd){
            alert("两次密码不一致，请重新输入！");return;
        }


        var p={phone:phone, yzm:yzm, password:pwd, type:xx};
        console.log(p);
        $.post(webSiteUrl+'/app/public/forgeter',p,function(ret){
            //var ret=jQuery.parseJSON(ret);
            if(ret.code==200){
                alert(ret.msg);
                loginPlay();
            }else{alert(ret.msg)}
        });

    }
</script>
</html>
